<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>学生信息管理-修改</title>
    <style>
        tr:last-child > td {
            text-align: center;
        }

        tr > td:first-child {
            font-weight: bold;

        }

        td {
            background-color: chocolate;
        }

    </style>
</head>
<body>
<div align="center">
    <h3>学生信息管理系统</h3>
    <table border="1" width="40%">
        <form action="/student/update" method="post">

            <input type="hidden" name="id" value="${stu.id}">
            <tr>
                <td>姓名:</td>
                <td><input type="text" id="name" name="name" value="${stu.name}"></td>
            </tr>
            <tr>
                <td>出生日期:</td>
                <td><input type="date" id="birthday" name="birthday" value="${stu.birthdayStr}"></td>
            </tr>
            <tr>
                <td>性别:</td>
                <td>
                    <c:if test="${stu.gender == 1}">
                        <input type="radio" name="gender" value="1" checked> 男
                        <input type="radio" name="gender" value="0"> 女
                    </c:if>
                    <c:if test="${stu.gender == 0}">
                        <input type="radio" name="gender" value="1"> 男
                        <input type="radio" name="gender" value="0" checked> 女
                    </c:if>
                </td>
            </tr>
            <tr>
                <td>电话:</td>
                <td><input type="text" id="phone" name="phone" value="${stu.phone}"></td>
            </tr>
            <tr>
                <td>地址:</td>
                <td><input type="text" id="address" name="address" value="${stu.address}"></td>
            </tr>
            <tr>
                <td colspan="2" style="background-color: white">
                    <input type="submit" value="提交">&emsp;
                    <input type="reset" value="重置">
                </td>
            </tr>
        </form>
    </table>
</div>
<script src="../../statics/js/jquery-3.6.3.min.js"></script>
<script>
    $("form").submit(function () {
        let name = $("#name").val();
        if (name == "") {
            alert("姓名不能为空！")
            return false;
        }

        let birthday = $("#birthday").val();
        if (birthday == "") {
            alert("出生日期不能为空！")
            return false;
        }
        let phone = $("#phone").val();
        if (phone == "") {
            alert("电话不能为空！")
            return false;
        }
        let address = $("#address").val();
        if (address == "") {
            alert("地址不能为空！")
            return false;
        }
        return true;
    })
</script>
</body>
</html>